class Solution(object):
    def isValid(self, s):
        ans = []
        m = {")": "(", "}": "{", "]": "["}
        for char in s:
            if char in m:
                top=ans.pop() if ans else '#'
                if m[char]!=top:
                    return False

            else:
                ans.append(char)
        
        return not ans
s="()"
print(Solution().isValid(s))
